﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Abp.Auditing;
using Abp.Domain.Entities;
using Abp.Domain.Entities.Auditing;
using KelonProud.Extensions;
using KelonProud.MultiTenancy;
using Oracle.ManagedDataAccess.Types;

namespace KelonProud.Administration.Domain.Authorization
{
    [Table("KpNavigation")]
    public class Navigation:Entity,IMayHaveTenant,IAudited
    {
        [Column("ParentId")]
        public virtual int? ParentId { get; set; }

        [Column("Name")]
        [StringLength(100)]
        public virtual string Name { get; set; }

        [Column("Code")]
        [StringLength(100)]
        public virtual string Code { get; set; }

        [Column("ActionUrl")]
        [StringLength(100)]
        public virtual string ActionUrl { get; set; }

        [Column("Icon")]
        [StringLength(50)]
        public virtual string Icon { get; set; }

        [Column("IsHide")]
        public virtual bool IsHide { get; set; }

        [Column("Level")]
        public virtual byte Level { get; set; }

        [Column("Order")]
        public virtual byte Order { get; set; }

        [Column("IdPath")]
        [StringLength(100)]
        public virtual string IdPath { get; set; }

        [Column("NamePath")]
        [StringLength(100)]
        public virtual string NamePath { get; set; }

        [Column("Type")]
        public virtual NavigationType Type { get; set; }

        [Column("Description")]
        [StringLength(300)]
        public virtual string Description { get; set; }

        [Column("TenantId")]
        public int? TenantId { get; set; }

        [ForeignKey("TenantId")]
        public virtual Tenant Tenant { get; set; }

        [Column("CreationTime")]
        public DateTime CreationTime { get; set; }

        [Column("CreatorUserId")]
        public long? CreatorUserId { get; set; }

        [ForeignKey("CreatorUserId")]
        public virtual User CreatorUser { get; set; }

        [Column("LastModificationTime")]
        public DateTime? LastModificationTime { get; set; }

        [Column("LastModifierUserId")]
        public long? LastModifierUserId { get; set; }

        [ForeignKey("ParentId")]
        [DisableAuditing]
        public virtual Navigation Parent { get; set; }

        [DisableAuditing]
        [ForeignKey("ParentId")]
        public virtual ICollection<Navigation> Children { get; set; }

        [ForeignKey("NavigationId")]
        public virtual ICollection<NavigationRole> Roles { get; set; }

        [ForeignKey("NavigationId")]
        public virtual ICollection<EditionNavigation> Editions { get; set; }
    }

    public enum NavigationType:byte
    {
        [EnumDisplay("菜单")]
        Menu = 0,
        [EnumDisplay("功能")]
        Action = 1
    }
}
